package com.zhaotianhao.basicservice.controller;


import com.alibaba.fastjson.JSON;
import com.zhaotianhao.basicservice.common.JsonResult;
import com.zhaotianhao.basicservice.entity.Type;
import com.zhaotianhao.basicservice.service.ITypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 房源类型 前端控制器
 * </p>
 *
 * @author Z-7
 * @since 2022-05-16
 */
@RestController
@RequestMapping("/type")
public class TypeController {
    @Autowired
    private ITypeService iTypeService;

    @GetMapping("getAllType")
    public JsonResult getAllType() {
        List<Type> list = iTypeService.list();
        return JsonResult.successd(JSON.toJSONString(list));
    }

    @GetMapping("getAll")
    public JsonResult getAll() {
        List<Type> list = iTypeService.list();
        return JsonResult.successd(list);
    }

    @GetMapping("getById")
    public Type getById(Integer id) {
        Type type = iTypeService.getById(id);
        return type;
    }
}
